package com.xzit.controller;

import com.xzit.entity.Student;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//@Controller
//如果当前controller中所有方法都以json返回，使用@RestController
@RestController
public class JsonController {

    @RequestMapping("returnJson")
    //使用下面的注解，表明当前方法以json格式返回
    //@ResponseBody
    public Object returnJson(){
        Student student=new Student();
        student.setId(10).setName("王某").setAge(20).setGender("男");
        return student;
    }

}
